package br.com.sig.presentation.component;

import java.io.IOException;

import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;

@FacesComponent(UIInputContainer.COMPONENT_TYPE)
public class UIInputContainer extends org.jboss.seam.faces.component.UIInputContainer {
	
	public static final String COMPONENT_TYPE = "br.com.sig.presentation.component.InputContainer";

	@Override
	public void encodeBegin(FacesContext context) throws IOException {
		super.encodeBegin(context);
		
		InputContainerElements elements = scan(getFacet(UIComponent.COMPOSITE_FACET_NAME), null, context);
		
        if (elements.hasValidationError()) {
            getAttributes().put(getInvalidAttributeName(), true);
        } else {
        	getAttributes().put(getInvalidAttributeName(), false);
        }
	}
}
